In [1]:
%matplotlib inline
In [2]:
import pandas as pd
import numpy as np
import seaborn as sns
import matplotlib.pyplot as plt
In [3]:
sns.set(style='whitegrid')
In [4]:
inputData = pd.read_csv('~/Documents/2015-2016/499P/code/BrainPowerLogs/Input/2015-11-30_12-33-29', names= ['time', 'src', 'dest', 'inhibitor'])
In [5]:
firingData = pd.read_csv('~/Documents/2015-2016/499P/code/BrainPowerLogs/Firing/2015-11-30_12-33-29', names= ['time', 'neuron', 'fired'])
In [6]:
# time steps
ex = []
ix = []
time_range = 10
# excitatory signals
e = []
# inhibitory signals
i = []
In [7]:
# An example of how we filter the input data for each neuron
# In this example, neuron 817 fired at time 348 and we filter input based on these
inputData[(inputData.dest==817)&(inputData.time<348)&(inputData.time>(348-time_range))]
Out[7]:
In [8]:
for fire_data in firingData.values:
# time stamp when output occurred
t = fire_data[0]
# the neuron of interest
n = fire_data[1]
# filter by neuron and time range
filtered_input = inputData[(inputData.dest==n)&(inputData.time<t)&(inputData.time>(t-time_range))]
for row in filtered_input.values:
if row[3]:
ix.append(time_range-(t-row[0]))
i.append(n)
else:
ex.append(time_range-(t-row[0]))
e.append(n)
In [9]:
plt.scatter(ex, e, c='g')
plt.scatter(ix, i, c='r')
plt.show()
In [13]:
sum_ex = [0]*(time_range+1)
sum_ix = [0]*(time_range+1)
for k in ex:
sum_ex[k]+=1
for k in ix:
sum_ix[k]+=1
In [14]:
index = np.arange(time_range+1)
bar_width = 0.35
opacity=1
rects1 = plt.bar(index, sum_ex, bar_width,
alpha=opacity,
color='g',
label='Excitatory')
rects2 = plt.bar(index + bar_width, sum_ix, bar_width,
alpha=opacity,
color='r',
label='Inhibitory')
plt.xlabel('Time Step')
plt.ylabel('Sum Inputs')
plt.title('Total input signals at time step before output')
plt.legend()
plt.tight_layout()
plt.show()
In [15]:
regionsData = pd.read_csv('~/Documents/2015-2016/499P/code/BrainPowerLogs/Region/2015-11-30_12-33-29', index_col='neuron', names= ['neuron', 'region'])
In [16]:
firing_and_regions = pd.merge(firingData, regionsData, left_on='neuron', right_index=True)
firing_and_regions.head()
Out[16]:
In [17]:
regionsData = regionsData.rename(columns={'neuron':'src','region':'src_region'})
input_and_regions = pd.merge(inputData, regionsData, left_on='src', right_index=True)
regionsData = regionsData.rename(columns={'src':'dest','src_region':'dest_region'})
input_and_regions = pd.merge(input_and_regions, regionsData, left_on='dest', right_index=True)
input_and_regions.head()
Out[17]:
In [24]:
# clear data
ex = []
ix = []
# excitatory signals
e = []
# inhibitory signals
i = []
In [25]:
# An example of what our filtered data looks like.
# It ignores firing within a region.
# In this example, region 92 fired at time 300 and we track the inputs leading up to this.
input_and_regions[(input_and_regions.dest_region==92)&(input_and_regions.src_region!=92)&(input_and_regions.time<300)&(input_and_regions.time>(300-time_range))]
Out[25]:
In [26]:
firing_and_regions.head()
Out[26]:
In [27]:
for fire_data in firing_and_regions.values:
region = fire_data[3]
t = fire_data[0]
# filter out firing w/in regions
filtered_input = input_and_regions[(input_and_regions.dest_region==region)&(input_and_regions.src_region!=region)&(input_and_regions.time<t)&(input_and_regions.time>(t-time_range))]
for row in filtered_input.values:
if row[3]:
ix.append(time_range-(t-row[0]))
i.append(region)
else:
ex.append(time_range-(t-row[0]))
e.append(region)
In [30]:
plt.scatter(ex, e, c='g')
plt.scatter(ix, i, c='r')
plt.show()
In [31]:
sum_ex = [0]*(time_range+1)
sum_ix = [0]*(time_range+1)
for k in ex:
sum_ex[k]+=1
for k in ix:
sum_ix[k]+=1
In [32]:
index = np.arange(time_range+1)
bar_width = 0.35
opacity=1
rects1 = plt.bar(index, sum_ex, bar_width,
alpha=opacity,
color='g',
label='Excitatory')
rects2 = plt.bar(index + bar_width, sum_ix, bar_width,
alpha=opacity,
color='r',
label='Inhibitory')
plt.xlabel('Time Step')
plt.ylabel('Sum Inputs')
plt.title('Total input signals at time step before output')
plt.legend()
plt.tight_layout()
plt.show()